package com.ml.mall.mapper.coupon;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ml.mall.bean.res.coupon.CouponProductRes;
import com.ml.mall.entity.coupon.SysCouponProductRelation;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface SysCouponProductRelationMapper extends BaseMapper<SysCouponProductRelation> {
    /**
     * @description    :通过优惠券id删除相关联的商品
     * @author         :zxm
     * @date           :2021/5/21
    **/
    @Delete("delete from sys_coupon_product_relation where coupon_code = #{couponCode} ")
    int deleteByCouponCode(@Param("couponCode") String couponCode);

    /**
     * @description    :通过优惠券id查询相关联的商品
     * @author         :zxm
     * @date           :2021/5/21
    **/
    List<CouponProductRes> selectProductByCouponCode(@Param("couponCode") String couponCode);

    /**
     * @description    :查询商品能否使用某优惠券
     * @author         :zxm
     * @date           :2021/5/28
    **/
    Long countProductUsableCoupon(@Param("couponCode") String couponCode, @Param("variantId") Long variantId);
}